/*
* @(#)StepInformationWindow.java
*
* Copyright (c) 2004 DCIVision Ltd
* All rights reserved.
*
* This software is the confidential and proprietary information of DCIVision
* Ltd ("Confidential Information").  You shall not disclose such Confidential
* Information and shall use it only in accordance with the terms of the license
* agreement you entered into with DCIVision Ltd.
*/

package com.dcivision.workflow.applet.editor;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.io.ObjectInputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.util.Vector;

import javax.servlet.ServletException;
import javax.swing.ButtonGroup;
import javax.swing.DefaultListModel;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.JToggleButton;
import javax.swing.SwingConstants;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

import org.jgraph.graph.DefaultGraphCell;
import org.jgraph.pad.GPUserObject;

import com.dcivision.dms.client.HtmlFormText;
import com.dcivision.form.bean.FormSection;
import com.dcivision.framework.Utility;
import com.dcivision.user.bean.UserGroup;
import com.dcivision.user.bean.UserRecord;
import com.dcivision.user.bean.UserRole;
import com.dcivision.workflow.applet.AppletResource;
import com.dcivision.workflow.applet.JIntegerTextField;
import com.dcivision.workflow.applet.ListObject;
import com.dcivision.workflow.applet.WindowUtilities;
import com.dcivision.workflow.applet.net.HttpOperation;
import com.dcivision.workflow.bean.WorkflowAction;
import com.dcivision.workflow.bean.WorkflowStep;



/**
    StepInformationWindow.java

    @author          Beyond
    @company         DCIVision Limited
    @creation date   27/08/2004
    @version         $Revision: 1.16 $
    */

public class StepInformationWindow extends JDialog {

  public static final String REVISION = "$Revision: 1.16 $";
  Vector checkboxes = new Vector();
  String getDataURL = "/workflow/appletMiddleware?dataType=GET_CATEGORYGROUP";
  JList groupList = new JList();
  DefaultGraphCell cell;
  Editor editor;

//Define URL
  String hostURL = "";
  //

  String navMode        = "N";
  String opMode         = "INS";
  String ID             = "";
  String recordStatus   = "";
  String updateCount    = "";
  String creatorID      = "";
  String createDate     = "";
  String updaterID      = "";
  String updateDate     = "";
  Integer groupID ;
  String stepSeq = null;
  String workflowRecordID = null;
  String priorityRuleListValue = null;
  String notificationRuleListValue = null;
  
  String notificationOwner = null;
  HttpOperation httpOperation = null;
  JButton jButton4 = new JButton();
  JButton jButton5 = new JButton();
  JCheckBox jCB1ByMail = new JCheckBox();
  JCheckBox jCB1BySystem = new JCheckBox();
  JCheckBox jCB2ByMail = new JCheckBox();
  JCheckBox jCB2BySystem = new JCheckBox();
  JCheckBox jCB3ByMail = new JCheckBox();
  JCheckBox jCB3BySystem = new JCheckBox();
  JCheckBox jCB4ByMail = new JCheckBox();
  JCheckBox jCB4BySystem = new JCheckBox();
  JComboBox jCBActionAfterDueDate1 = new JComboBox();
  JComboBox jCBActionAfterDueDate2 = new JComboBox();
  JComboBox jCBFitterBy = new JComboBox();
  //JScrollPane jListUser = new JScrollPane();

  JLabel jLabel1 = new JLabel();
  JLabel jLabel10 = new JLabel();
  JLabel jLabel11 = new JLabel();
  JLabel jLabel12 = new JLabel();
  JLabel jLabel13 = new JLabel();
  JLabel jLabel14 = new JLabel();
  JLabel jLabel15 = new JLabel();
  JLabel jLabel16 = new JLabel();
  JLabel jLabel17 = new JLabel();
  JLabel jLabel18 = new JLabel();
  JLabel jLabel19 = new JLabel();
  JLabel jLabel2 = new JLabel();
  JLabel jLabel20 = new JLabel();
  JLabel jLabel21 = new JLabel();
  JLabel jLabel22 = new JLabel();
  JLabel jLabel23 = new JLabel();
  JLabel jLabel3 = new JLabel();
  JLabel jLabel5 = new JLabel();
  JLabel jLabel6 = new JLabel();
  JLabel jLabel7 = new JLabel();
  JLabel jLabel8 = new JLabel();
  JLabel jLabel9 = new JLabel();
  JPanel jPanel1 = new JPanel();
  JPanel jPanel2 = new JPanel();
  JPanel jPanel3 = new JPanel();
  JPanel jPanel4 = new JPanel();

  JRadioButton jRBDueDate1 = new JRadioButton();
  JRadioButton jRBDueDate2 = new JRadioButton();
  JRadioButton jRBDueDate3 = new JRadioButton();
  JRadioButton jRBHight = new JRadioButton();
  JRadioButton jRBLow = new JRadioButton();
  JRadioButton jRBMiddle = new JRadioButton();
  JRadioButton jRStopFalse = new JRadioButton();
  JRadioButton jRStopTrue = new JRadioButton();
  JTabbedPane jTabbedPane1 = new JTabbedPane();
  JTextArea jTADescript = new JTextArea();
  JTextField jTFOnNoResponseAfter = new JTextField();
  JIntegerTextField jTFOnNoResponseFor = new JIntegerTextField(0,999999999,0);
  JIntegerTextField jTFRule = new JIntegerTextField(0,1000,1);
  JIntegerTextField jTFSequenceNumber = new JIntegerTextField(0,999999999,0);
  JTextField jTFStepName = new JTextField();

  String maintWorkflowRecordURL = "/workflow/MaintAppletStep.do";
  JList roleList = new JList();
  JPanel suffixList = new JPanel();
  JList userList = new JList();
  JList formSectionEList = new JList();
  JList formSectionRList = new JList();

  JScrollPane jListGroup = new JScrollPane(groupList);
  JScrollPane jListRole = new JScrollPane(roleList);
  JScrollPane jListUser = new JScrollPane(userList);
  JScrollPane jSPEdit = new JScrollPane(formSectionEList);
  JScrollPane jSPRead = new JScrollPane(formSectionRList);


  public WorkflowStepRecord workflowStepRecord ;
  WorkflowStep stepInfo = null;
  JLabel jLabel4 = new JLabel();

  JLabel jLabel24 = new JLabel();
  JLabel jLabel25 = new JLabel();
  JLabel jLabel26 = new JLabel();
  JRadioButton jRBDueDate4 = new JRadioButton();
  JCheckBox jCBallowAssignDueDate = new JCheckBox();
  JLabel jLabel27 = new JLabel();
  JComboBox jCBStepType = new JComboBox();
  JScrollPane jSPSpecialActor = new JScrollPane();
  JList jListSpecialActor = new JList();
  JCheckBox jCBAssign = new JCheckBox();
  JButton jBPriority = new JButton();
  JToggleButton jBNotification = new JToggleButton();
  String stepType="T";


  public StepInformationWindow() {
    this(null, "", false);
  }

  public StepInformationWindow(Frame frame, String title, boolean modal) {
    super(frame, title, modal);
    try {
      jbInit();
      pack();
    }
    catch(Exception ex) {
      ex.printStackTrace();
    }
  }
  public StepInformationWindow(HttpOperation httpOperation,String hostURL) {
    super();
    this.httpOperation = httpOperation;
    this.hostURL = hostURL;
    try {
      jbInit();
      pack();
    }
    catch(Exception ex) {
      ex.printStackTrace();
    }
  }

  public StepInformationWindow(WorkflowStepRecord workflowStepRecord,String hostURL,HttpOperation httpOperation) {
    this(null, "", false);
    this.hostURL = hostURL;
    this.httpOperation = httpOperation;
    //init user,role,group list
    initList();
    this.workflowStepRecord = workflowStepRecord ;
    setRecordToWindow();
  }

  public StepInformationWindow(Object obj, String workflowRecordID, String hostURL,HttpOperation httpOperation) {
    this(null, "", false);
    this.hostURL = hostURL;
    this.workflowRecordID = workflowRecordID;
    this.httpOperation = httpOperation;
    GPUserObject userObject = (GPUserObject)obj;
    this.stepType = userObject.getProperty("STEPTYPE").toString();    
    //init user,role,group list
    initList();
    String[] objArr = WindowUtilities.splitString(obj.toString(), ".");
    if(obj.toString().indexOf('.')>0){
      this.stepSeq = objArr[0];
    }
    setRecordToWindow();
  }

  /**
   * addCheckBox
   *
   * @param objectType
   * @param userObject
   * @param selected
   *
   */
  public void addCheckBox(String objectType ,Object userObject, boolean selected) {
    if("User".equals(objectType)){
        JCheckBox cb = (JCheckBox) jListUser.add(new JCheckBox(((ExtendUserRecord)userObject).toString()));
        cb.setText(((ExtendUserRecord)userObject).getID().toString());
        checkboxes.addElement(cb);
        cb.setSelected(selected);
    }else if("Group".equals(objectType)){
        JCheckBox cb = (JCheckBox) jListGroup.add(new JCheckBox(((ExtendGroupRecord)userObject).toString()));
        checkboxes.addElement(cb);
        cb.setSelected(selected);
    }else if("Role".equals(objectType)){
        JCheckBox cb = (JCheckBox) jListRole.add(new JCheckBox(((ExtendRoleRecord)userObject).toString()));
        checkboxes.addElement(cb);
        cb.setSelected(selected);
    }
    //cb.addActionListener(suffixAction);

  }

  public WorkflowStepRecord getWorkflowStepRecord(){
    return this.workflowStepRecord;
  }

  public Object getCell(){
    return this.cell;
  }

  public void setCell(Object cell){
    this.cell = (DefaultGraphCell)cell;
  }

  public Editor getEditor(){
    return this.editor;
  }

  public void setEditor(Editor editor){
    this.editor = editor;
  }

  public void initList(){
    ObjectInputStream inputFromServlet = null;
    List userRecordList = new ArrayList();
    List userGroupList = new ArrayList();
    List userRoleList = new ArrayList();
    String[][] specialActor ;
    List formSectionList = new ArrayList();
    List stepList = new ArrayList();
    List autoTaskTypeList = new ArrayList();

    getDataURL  = "/workflow/appletMiddleware?dataType=GET_USERINFO"+"&workflowRecordID="+workflowRecordID;
    try{
      inputFromServlet = httpOperation.getObjectInputStreamFromServlet(getDataURL);

      if(inputFromServlet == null){
        return;
      }
      Object obj = null;
      //obj = inputFromServlet.readObject();
    //  get bind list for select
      obj = inputFromServlet.readObject();
      if (obj instanceof List) {
        userRecordList = (List) obj;
      } else if (obj instanceof Exception) {
        //otherwise type cast it to Exception and throw that exception.
      throw (Exception) obj;
      }
      obj = inputFromServlet.readObject();
      if (obj instanceof List) {
        userGroupList = (List) obj;
      } else if (obj instanceof Exception) {
        //otherwise type cast it to Exception and throw that exception.
      throw (Exception) obj;
      }
      obj = inputFromServlet.readObject();
      if (obj instanceof List) {
        userRoleList = (List) obj;
      } else if (obj instanceof Exception) {
        //otherwise type cast it to Exception and throw that exception.
      throw (Exception) obj;
      }
      obj = inputFromServlet.readObject();
      specialActor = (String[][]) obj;

      obj = inputFromServlet.readObject();
      if (obj instanceof List) {
        formSectionList = (List) obj;
      } else if (obj instanceof Exception) {
        //otherwise type cast it to Exception and throw that exception.
      throw (Exception) obj;
      }
      obj = inputFromServlet.readObject();
      if (obj instanceof List) {
        stepList = (List) obj;
      } else if (obj instanceof Exception) {
        //otherwise type cast it to Exception and throw that exception.
      throw (Exception) obj;
      }

      obj = inputFromServlet.readObject();
      if (obj instanceof List) {
        autoTaskTypeList = (List) obj;
      } else if (obj instanceof Exception) {
        //otherwise type cast it to Exception and throw that exception.
      throw (Exception) obj;
      }

      DefaultListModel listUserModel = new DefaultListModel();
      DefaultListModel listGroupModel = new DefaultListModel();
      DefaultListModel listRoleModel = new DefaultListModel();
      DefaultListModel listSpecialModel = new DefaultListModel();
      DefaultListModel listFormSectionEModel = new DefaultListModel();
      DefaultListModel listFormSectionRModel = new DefaultListModel();
      DefaultListModel listStepModel = new DefaultListModel();
      for(int i=0; i<userRecordList.size() ; i++) {
        UserRecord userRecord = (UserRecord)userRecordList.get(i);
        Integer objID = null;
        String objText = null;
        //Method getIDMethod = Class.forName(className).getMethod("getID", null);
        //Method getTextMethod = Class.forName(className).getMethod(methodName, null);
        objID = userRecord.getID();
        objText = userRecord.getFullName();
        ListObject workflowUserInfo = new ListObject();
        workflowUserInfo.setID(objID.toString());
        workflowUserInfo.setName(objText);
        listUserModel.addElement(workflowUserInfo);
      }
      userList.setModel(listUserModel);
      for(int i=0; i<userGroupList.size() ; i++) {
        UserGroup userGroup = (UserGroup)userGroupList.get(i);
        Integer objID = null;
        String objText = null;
        //Method getIDMethod = Class.forName(className).getMethod("getID", null);
        //Method getTextMethod = Class.forName(className).getMethod(methodName, null);
        objID = userGroup.getID();
        objText = userGroup.getGroupName();
        ListObject workflowUserInfo = new ListObject();
        workflowUserInfo.setID(objID.toString());
        workflowUserInfo.setName(objText);
        listGroupModel.addElement(workflowUserInfo);

      }
      groupList.setModel(listGroupModel);
      for(int i=0; i<userRoleList.size() ; i++) {
        UserRole userRole = (UserRole)userRoleList.get(i);
        Integer objID = null;
        String objText = null;
        objID = userRole.getID();
        objText = userRole.getRoleName();
        ListObject workflowUserInfo = new ListObject();
        workflowUserInfo.setID(objID.toString());
        workflowUserInfo.setName(objText);
        listRoleModel.addElement(workflowUserInfo);
      }
      roleList.setModel(listRoleModel);

      for(int i=0; i<specialActor.length ; i++) {
        String objID = null;
        String objText = null;
        objID = specialActor[i][1];
        objText = specialActor[i][0];
        ListObject workflowUserInfo = new ListObject();
        workflowUserInfo.setID(objID);
        workflowUserInfo.setName(objText);
        listSpecialModel.addElement(workflowUserInfo);
      }
      jListSpecialActor.setModel(listSpecialModel);

      for(int i=0; i<formSectionList.size() ; i++) {
        FormSection formSection = (FormSection)formSectionList.get(i);
        Integer objID = null;
        String objText = null;
        //Method getIDMethod = Class.forName(className).getMethod("getID", null);
        //Method getTextMethod = Class.forName(className).getMethod(methodName, null);
        objID = formSection.getID();
        objText = formSection.getTitle();
        ListObject formSectionInfo = new ListObject();
        formSectionInfo.setID(objID.toString());
        formSectionInfo.setName(objText);
        listFormSectionEModel.addElement(formSectionInfo);
      }
      formSectionEList.setModel(listFormSectionEModel);

      for(int i=0; i<formSectionList.size() ; i++) {
        FormSection formSection = (FormSection)formSectionList.get(i);
        Integer objID = null;
        String objText = null;
        //Method getIDMethod = Class.forName(className).getMethod("getID", null);
        //Method getTextMethod = Class.forName(className).getMethod(methodName, null);
        objID = formSection.getID();
        objText = formSection.getTitle();
        ListObject formSectionInfo = new ListObject();
        formSectionInfo.setID(objID.toString());
        formSectionInfo.setName(objText);
        listFormSectionRModel.addElement(formSectionInfo);
      }
      formSectionRList.setModel(listFormSectionRModel);
      //jCBActionAfterDueDate2
      for(int i=0; i<stepList.size() ; i++) {
        WorkflowStep workflowStep = (WorkflowStep)stepList.get(i);
        Integer objID = null;
        String objText = null;
        objID = workflowStep.getID();
        objText = workflowStep.getStepSeq()+"."+workflowStep.getStepName();
        ListObject workflowStepInfo = new ListObject();
        workflowStepInfo.setID(objID.toString());
        workflowStepInfo.setName(objText);
        jCBActionAfterDueDate2.addItem(workflowStepInfo);
      }      
      if(!"C".equals(stepType.substring(0,1))){
        String[][] stepTypeAry = {
            {"S",AppletResource.lableArr[85]},
            {"E",AppletResource.lableArr[153]},
            {"T",AppletResource.lableArr[152]},
            {"A",AppletResource.lableArr[151]},
            {"B",AppletResource.lableArr[154]},
            {"F",AppletResource.lableArr[155]},
            {"U",AppletResource.lableArr[156]}};
        for(int i=0;i<stepTypeAry.length;i++){
          ListObject commonStepType= new ListObject();
          commonStepType.setID(stepTypeAry[i][0]);
          commonStepType.setName(stepTypeAry[i][1]);
          jCBStepType.addItem(commonStepType);
        } 
      } else {
        for(int i=0; i<autoTaskTypeList.size() ; i++) {
          WorkflowAction workflowAction = (WorkflowAction)autoTaskTypeList.get(i);
          String objID = null;
          String objText = null;
          objID = WorkflowStep.ACTION_TYPE_SYSTEM_AUTO + workflowAction.getID().toString();
          objText = workflowAction.getActionLabel();
          ListObject stepType= new ListObject();
          stepType.setID(objID);
          stepType.setName(objText);
          jCBStepType.addItem(stepType);
        }
      }
            
    }catch(Exception e){
      e.printStackTrace();
    }
  }

  /**
   * jbInit
   *
   */
  private void jbInit() throws Exception {
    ButtonGroup group1 = new ButtonGroup();
    ButtonGroup group2 = new ButtonGroup();
    ButtonGroup group3 = new ButtonGroup();
    ButtonGroup group4 = new ButtonGroup();


    //JScrollPane scrollPane = new JScrollPane(jListUser);
    //     scrollPane.getVerticalScrollBar().setUnitIncrement(10);
    //jPanel2.add(scrollPane);
    //jPanel2.add(Box.createRigidArea(new Dimension(10,1)));

    this.getContentPane().setLayout(null);
    jPanel1.setBounds(new Rectangle(0, 1, 604, 377));
    jPanel1.setLayout(null);
    jTFRule.setText("");
    jTFRule.setBounds(new Rectangle(155, 9, 57, 22));
    jRBDueDate1.setSelected(true);
    jRBDueDate1.addChangeListener(new ChangeListener(){
      public void stateChanged(ChangeEvent e){
        JRadioButton source = (JRadioButton)e.getSource();
        if(source.isSelected()){
          jTFOnNoResponseAfter.setText("");
          jTFOnNoResponseFor.setText("");
        }
      }
    });
    jRBDueDate1.setText(AppletResource.lableArr[109]);
    jRBDueDate1.setBounds(new Rectangle(152, 33, 53, 20));
    jCB2BySystem.setText("");
    jCB2BySystem.setBounds(new Rectangle(500, 191, 26, 25));
    jTFOnNoResponseFor.setText("");
    jTFOnNoResponseFor.setBounds(new Rectangle(174, 54, 57, 20));
    jRBDueDate2.setText("");
    jRBDueDate2.setBounds(new Rectangle(152, 51, 21, 25));
    jRBDueDate2.addChangeListener(new ChangeListener(){
      public void stateChanged(ChangeEvent e){
        JRadioButton source = (JRadioButton)e.getSource();
        if(source.isSelected()){
          jTFOnNoResponseAfter.setText("");
        }
      }
    });
    jRBDueDate3.setToolTipText("");
    jRBDueDate3.setText("");
    jRBDueDate3.setBounds(new Rectangle(152, 77, 23, 25));
    jRBDueDate3.addChangeListener(new ChangeListener(){
      public void stateChanged(ChangeEvent e){
        JRadioButton source = (JRadioButton)e.getSource();
        if(source.isSelected()){
          jTFOnNoResponseFor.setText("");
        }
      }
    });
    jLabel14.setText(AppletResource.lableArr[70]);
    jLabel14.setBounds(new Rectangle(229, 12, 240, 16));
    jTFOnNoResponseAfter.setText("");
    jTFOnNoResponseAfter.setBounds(new Rectangle(175, 77, 146, 19));
    jCB1BySystem.setText("");
    jCB1BySystem.setBounds(new Rectangle(500, 174, 34, 22));
    jLabel9.setHorizontalAlignment(SwingConstants.RIGHT);
    jLabel9.setText(AppletResource.lableArr[71]+":");
    jLabel9.setBounds(new Rectangle(3, 61, 81, 16));
    jLabel16.setText(AppletResource.lableArr[72]);
    jLabel16.setBounds(new Rectangle(496, 159, 80, 16));
    jLabel18.setText(AppletResource.lableArr[74]);
    jLabel18.setBounds(new Rectangle(116, 195, 329, 16));
    jTADescript.setText("");
    jTADescript.setBounds(new Rectangle(121, 112, 331, 71));
    jCBActionAfterDueDate2.setBounds(new Rectangle(386, 132, 140, 18));
    jLabel17.setText(AppletResource.lableArr[75]);
    jLabel17.setBounds(new Rectangle(116, 175, 303, 16));
    jRBLow.setText(AppletResource.lableArr[78]);
    jRBLow.setBounds(new Rectangle(306, 59, 77, 23));
    jTFStepName.setText("new step");
    jTFStepName.setBounds(new Rectangle(290, 4, 167, 22));
    jCBActionAfterDueDate1.setBounds(new Rectangle(157, 132, 184, 19));
    jLabel6.setHorizontalAlignment(SwingConstants.RIGHT);
    jLabel6.setText(AppletResource.lableArr[107]+":");
    jLabel6.setBounds(new Rectangle(98, 9, 55, 16));
    jCB3ByMail.setText("");
    jCB3ByMail.setBounds(new Rectangle(446, 213, 32, 25));
    jTFSequenceNumber.setText("");
    jTFSequenceNumber.setBounds(new Rectangle(124, 4, 81, 22));
    jCB3BySystem.setText("");
    jCB3BySystem.setBounds(new Rectangle(499, 210, 32, 25));
    jLabel5.setText(AppletResource.lableArr[73]);
    jLabel5.setBounds(new Rectangle(429, 157, 51, 16));
    jLabel8.setHorizontalAlignment(SwingConstants.RIGHT);
    jLabel8.setText(AppletResource.lableArr[114]+":");
    jLabel8.setBounds(new Rectangle(12, 135, 141, 16));
    jLabel12.setText(AppletResource.lableArr[96]+":");
    jLabel12.setBounds(new Rectangle(202, 9, 120, 16));
    jPanel4.setDebugGraphicsOptions(0);
    jPanel4.setLayout(null);
    jLabel20.setText(AppletResource.lableArr[77]);
    jLabel20.setBounds(new Rectangle(116, 238, 303, 16));
    jCBFitterBy.setBounds(new Rectangle(260, 131, 204, 22));
    jLabel1.setForeground(Color.red);
    jLabel1.setText(AppletResource.lableArr[81]+":");
    jLabel1.setBounds(new Rectangle(6, 5, 130, 16));
    jLabel13.setText(AppletResource.lableArr[97]+":");
    jLabel13.setBounds(new Rectangle(382, 10, 100, 16));
    jLabel3.setHorizontalAlignment(SwingConstants.RIGHT);
    jLabel3.setText(AppletResource.lableArr[83]+":");
    jLabel3.setBounds(new Rectangle(3, 112, 80, 16));
    jPanel3.setLayout(null);
    jLabel2.setForeground(Color.red);
    jLabel2.setDebugGraphicsOptions(0);
    jLabel2.setText(AppletResource.lableArr[82]+":");
    jLabel2.setVerticalAlignment(SwingConstants.CENTER);
    jLabel2.setVerticalTextPosition(SwingConstants.CENTER);
    jLabel2.setBounds(new Rectangle(214, 5, 120, 16));
    jPanel2.setLayout(null);
    jPanel2.setPreferredSize(new Dimension(580, 311));
    jPanel2.setOpaque(true);
    jPanel2.setMaximumSize(new Dimension(32767, 32767));
    jPanel2.setMinimumSize(new Dimension(1, 1));
    jPanel2.setDebugGraphicsOptions(0);
    jPanel2.setAlignmentY((float) 0.5);
    jPanel2.setForeground(Color.red);
    jCB2ByMail.setText("");
    jCB2ByMail.setBounds(new Rectangle(446, 193, 32, 25));
    jCB1ByMail.setText("");
    jCB1ByMail.setBounds(new Rectangle(446, 173, 32, 25));
    jRBHight.setToolTipText("");
    jRBHight.setSelected(false);
    jRBHight.setText(AppletResource.lableArr[80]);
    jRBHight.setBounds(new Rectangle(122, 56, 74, 23));
    jLabel19.setText(AppletResource.lableArr[76]);
    jLabel19.setBounds(new Rectangle(116, 215, 304, 16));
    jButton5.setBounds(new Rectangle(306, 326, 86, 25));
    jButton5.setText(AppletResource.lableArr[25]);
    jButton5.addActionListener(new StepInformationWindow_jButton5_actionAdapter(this));
    jLabel11.setBounds(new Rectangle(17, 6, 100, 16));
    jLabel11.setText(AppletResource.lableArr[95]+":");
    jLabel7.setHorizontalAlignment(SwingConstants.RIGHT);
    jLabel7.setText(AppletResource.lableArr[108]+":");
    jLabel7.setBounds(new Rectangle(77, 53, 76, 16));
    jCB4BySystem.setText("");
    jCB4BySystem.setBounds(new Rectangle(499, 235, 35, 25));
    jButton4.setBounds(new Rectangle(173, 327, 79, 25));
    jButton4.setText(AppletResource.lableArr[24]);
    jButton4.addActionListener(new StepInformationWindow_jButton4_actionAdapter(this));
    jCB4ByMail.setText("");
    jCB4ByMail.setBounds(new Rectangle(446, 237, 32, 23));
    jRBMiddle.setSelected(true);
    jRBMiddle.setText(AppletResource.lableArr[79]);
    jRBMiddle.setBounds(new Rectangle(205, 59, 91, 21));
    jLabel15.setText(AppletResource.lableArr[110]);
    jLabel15.setBounds(new Rectangle(241, 55, 153, 16));
    jLabel10.setHorizontalAlignment(SwingConstants.RIGHT);
    jLabel10.setText(AppletResource.lableArr[120]+":");
    jLabel10.setBounds(new Rectangle(15, 155, 98, 16));
    jTabbedPane1.setBounds(new Rectangle(8, 6, 589, 314));
    jLabel21.setText(AppletResource.lableArr[145]+":");
    jLabel21.setBounds(new Rectangle(16, 204, 58, 16));
    jPanel3.setDebugGraphicsOptions(0);
    jLabel22.setText(AppletResource.lableArr[103]+":");
    jLabel22.setBounds(new Rectangle(193, 133, 61, 16));
    //jListUser.setBounds(new Rectangle(10, 54, 160, 94));

    jListUser.setBounds(new Rectangle(15, 30, 167, 97));
    jListGroup.setBounds(new Rectangle(191, 29, 173, 98));
    jListRole.setBounds(new Rectangle(372, 30, 184, 98));
    jLabel23.setToolTipText("");
    jLabel23.setHorizontalAlignment(SwingConstants.RIGHT);
    jLabel23.setText(AppletResource.lableArr[117]+":");
    jLabel23.setBounds(new Rectangle(3, 84, 81, 17));
    jRStopTrue.setText(AppletResource.lableArr[118]);
    jRStopTrue.setBounds(new Rectangle(122, 82, 74, 18));
    jRStopFalse.setBorderPainted(false);
    jRStopFalse.setText(AppletResource.lableArr[119]);
    jRStopFalse.setBounds(new Rectangle(205, 81, 68, 16));
    jLabel4.setHorizontalAlignment(SwingConstants.RIGHT);
    jLabel4.setText(AppletResource.lableArr[104]+":");
    jLabel4.setBounds(new Rectangle(3, 193, 81, 19));
    jSPEdit.setBounds(new Rectangle(121, 192, 130, 78));
    jSPRead.setBounds(new Rectangle(313, 193, 141, 78));
    jLabel24.setHorizontalAlignment(SwingConstants.RIGHT);
    jLabel24.setText(AppletResource.lableArr[105]+"");
    jLabel24.setBounds(new Rectangle(66, 219, 45, 21));
    jLabel25.setHorizontalAlignment(SwingConstants.RIGHT);
    jLabel25.setText(AppletResource.lableArr[106]+"");
    jLabel25.setBounds(new Rectangle(258, 218, 47, 23));
    jLabel26.setRequestFocusEnabled(true);
    jLabel26.setText("(YYYY-MM-DD hh:mm:ss)");
    jLabel26.setBounds(new Rectangle(329, 75, 170, 20));
    jRBDueDate4.setText(AppletResource.lableArr[112]);
    jRBDueDate4.setBounds(new Rectangle(152, 102, 144, 21));
    jCBallowAssignDueDate.setSelectedIcon(null);
    jCBallowAssignDueDate.setText(AppletResource.lableArr[113]);
    jCBallowAssignDueDate.setBounds(new Rectangle(311, 106, 108, 16));
    jLabel27.setRequestFocusEnabled(true);
    jLabel27.setHorizontalAlignment(SwingConstants.RIGHT);
    jLabel27.setText(AppletResource.lableArr[84]+"");
    jLabel27.setBounds(new Rectangle(3, 35, 81, 16));
    jCBStepType.setBounds(new Rectangle(122, 33, 337, 21));
    jCBStepType.addItemListener(new ItemListener(){
      public void itemStateChanged(ItemEvent event){
        //int state = event.getStateChange();
        //ListObject workflowCategoryRecord = (ListObject)event.getItem();
        // stepTypeCode = workflowCategoryRecord.getID();
        if(stepType.substring(0,1).equals("C")){
          enabledComponent(false);
        } else {
          enabledComponent(true);
        }

      }
    });
    jSPSpecialActor.setBounds(new Rectangle(82, 163, 280, 99));
    jCBAssign.setText(AppletResource.lableArr[92]);
    jCBAssign.setBounds(new Rectangle(15, 130, 170, 25));
    jBPriority.setBounds(new Rectangle(391, 58, 122, 22));
    jCBAssign.addChangeListener(new ChangeListener(){
      public void stateChanged(ChangeEvent e){
        JCheckBox source = (JCheckBox)e.getSource();
        if(source.isSelected()){
          jListSpecialActor.clearSelection();
          jListSpecialActor.setEnabled(false);          
        } else {
          jListSpecialActor.setEnabled(true);
        }
      }
    });
    jBPriority.setText(AppletResource.lableArr[149]);
    jBPriority.addActionListener(new StepInformationWindow_jBPriority_actionAdapter(this));
    jBNotification.setText(AppletResource.lableArr[149]);
    jBNotification.setBounds(new Rectangle(379, 260, 136, 25));
    jBNotification.addActionListener(new StepInformationWindow_jBNotification_actionAdapter(this));
    jPanel3.add(jTFSequenceNumber, null);


    jTabbedPane1.add(jPanel3, AppletResource.lableArr[142]);
    jTabbedPane1.add(jPanel2, AppletResource.lableArr[91]);
    jTabbedPane1.add(jPanel4, AppletResource.lableArr[143]);

    jPanel4.add(jTFRule, null);
    jPanel4.add(jLabel14, null);
    jPanel4.add(jRBDueDate1, null);
    jPanel4.add(jLabel15, null);
    jPanel4.add(jRBDueDate2, null);
    jPanel4.add(jRBDueDate3, null);
    jPanel4.add(jTFOnNoResponseAfter, null);
    jPanel4.add(jLabel26, null);
    jPanel4.add(jRBDueDate4, null);
    jPanel4.add(jCBallowAssignDueDate, null);
    jPanel4.add(jLabel7, null);
    jPanel4.add(jLabel6, null);
    jPanel4.add(jCBActionAfterDueDate1, null);
    jPanel4.add(jLabel8, null);
    jPanel4.add(jCBActionAfterDueDate2, null);
    jPanel4.add(jLabel5, null);
    jPanel4.add(jLabel10, null);
    jPanel4.add(jLabel16, null);
    jPanel4.add(jLabel18, null);
    jPanel4.add(jLabel20, null);
    jPanel4.add(jLabel19, null);
    jPanel4.add(jLabel17, null);
    jPanel4.add(jCB4ByMail, null);
    jPanel4.add(jCB3ByMail, null);
    jPanel4.add(jCB2ByMail, null);
    jPanel4.add(jCB1ByMail, null);
    jPanel4.add(jCB1BySystem, null);
    jPanel4.add(jCB3BySystem, null);
    jPanel4.add(jCB2BySystem, null);
    jPanel4.add(jCB4BySystem, null);
    jPanel4.add(jBNotification, null);
    jPanel4.add(jTFOnNoResponseFor, null);
    jPanel1.add(jButton4, null);
    jPanel1.add(jButton5, null);
    jPanel1.add(jTabbedPane1, null);
    this.getContentPane().add(jPanel1, null);


    jPanel2.add(jListUser, null);
    jPanel2.add(jLabel11, null);
    jPanel2.add(jLabel12, null);
    jPanel2.add(jLabel13, null);
    jPanel2.add(jListRole, null);
    jPanel2.add(jListGroup, null);
    jPanel2.add(jLabel22, null);
    jPanel2.add(jCBFitterBy, null);
    jPanel2.add(jLabel21, null);
    jPanel2.add(jSPSpecialActor, null);
    jPanel2.add(jCBAssign, null);
    jSPSpecialActor.getViewport().add(jListSpecialActor, null);

    //add owner list
//    jListRole.getViewport().add(new JCheckBox("Role"), null);
//    jListGroup.getViewport().add(new JCheckBox("Group"), null);
//    jListUser.getViewport().add(new JCheckBox("User"), null);


    group1.add(jRBLow);
    group1.add(jRBHight);
    group1.add(jRBMiddle);

    group2.add(jRBDueDate1);
    group2.add(jRBDueDate2);
    group2.add(jRBDueDate3);
    group2.add(jRBDueDate4);

    // StepType comb



    String onNoResponseActionArr[][] = {{"",AppletResource.lableArr[115]},{"K",AppletResource.lableArr[121]},{"S",AppletResource.lableArr[122]},{"O",AppletResource.lableArr[126]}};
    String filterByArr[][] = {{"",AppletResource.lableArr[115]},{"-1",AppletResource.lableArr[130]},{"-2",AppletResource.lableArr[131]},{"1",AppletResource.lableArr[132]},{"2",AppletResource.lableArr[133]},{"3",AppletResource.lableArr[134]},{"4",AppletResource.lableArr[135]},{"5",AppletResource.lableArr[136]},{"6",AppletResource.lableArr[137]},{"7",AppletResource.lableArr[138]},{"8",AppletResource.lableArr[139]},{"9",AppletResource.lableArr[140]},{"10",AppletResource.lableArr[141]}};
    for(int i=0;i<onNoResponseActionArr.length;i++){
     ListObject onNoResponseAction = new ListObject();
     onNoResponseAction.setID(onNoResponseActionArr[i][0]);
     onNoResponseAction.setName(onNoResponseActionArr[i][1]);
     jCBActionAfterDueDate1.addItem(onNoResponseAction);
    }
    for(int i=0;i<filterByArr.length;i++){
      ListObject filterBy = new ListObject();
      filterBy.setID(filterByArr[i][0]);
      filterBy.setName(filterByArr[i][1]);
      jCBFitterBy.addItem(filterBy);
     }

    jTFRule.setText("1");
    group3.add(jRStopTrue);
    group3.add(jRStopFalse);
    jPanel3.add(jLabel24, null);
    jPanel3.add(jTFStepName, null);
    jPanel3.add(jLabel2, null);
    jPanel3.add(jLabel1, null);
    jPanel3.add(jSPEdit, null);


    jPanel3.add(jRBHight, null);
    jPanel3.add(jRStopTrue, null);
    jPanel3.add(jCBStepType, null);
    jPanel3.add(jLabel3, null);
    jPanel3.add(jLabel4, null);
    jPanel3.add(jLabel23, null);
    jPanel3.add(jLabel9, null);
    jPanel3.add(jLabel27, null);
    jPanel3.add(jLabel25, null);
    jPanel3.add(jRBMiddle, null);
    jPanel3.add(jRStopFalse, null);
    jPanel3.add(jRBLow, null);
    jPanel3.add(jBPriority, null);
    jPanel3.add(jTADescript, null);
    jPanel3.add(jSPRead, null);
  }

  void jButton4_actionPerformed(ActionEvent e) {
    if(!checkValue()){
      return ;
    }
    setWindowInfoToRecord();
    this.dispose();
  }

  void jButton5_actionPerformed(ActionEvent e) {
    this.dispose();
  }

  void enabledComponent(boolean enabled){
    userList.setEnabled(enabled);
    roleList.setEnabled(enabled);
    groupList.setEnabled(enabled);
    jCBFitterBy.setEnabled(enabled);
    jRBDueDate1.setEnabled(enabled);
    jRBDueDate2.setEnabled(enabled);
    jRBDueDate3.setEnabled(enabled);
    jRBDueDate4.setEnabled(enabled);
    jTFOnNoResponseAfter.setEnabled(enabled);
    jCBActionAfterDueDate1.setEnabled(enabled);
    jCBActionAfterDueDate2.setEnabled(enabled);
    jRBHight.setEnabled(enabled);
    jRBMiddle.setEnabled(enabled);
    jRBLow.setEnabled(enabled);
    jTFOnNoResponseFor.setEnabled(enabled);
    jCBStepType.setEnabled(!enabled);
  }

  /**
   * login to System
   *
   * Set logind return headinformation(sessionid).
   *
   *
   * @param strUrl
   * @throws ServletException exception
   *
   * @return is login sucessful.
   *
   */
  public void setRecordToWindow(){
    ObjectInputStream inputFromServlet = null;
    String nextStepSeq = null;

    getDataURL  = "/workflow/appletMiddleware?dataType=GET_STEPINFO&stepSeq="+stepSeq+"&workflowRecordID="+workflowRecordID;
    try{
      inputFromServlet = httpOperation.getObjectInputStreamFromServlet(getDataURL);

      if(inputFromServlet == null){
        return;
      }

      Object obj = null;
      //obj = inputFromServlet.readObject();
    //  get bind list for select
      obj = inputFromServlet.readObject();

      if (obj instanceof String) {
        nextStepSeq = obj.toString();
      } else if (obj instanceof Exception) {
        //otherwise type cast it to Exception and throw that exception.
      throw (Exception) obj;
      }
      obj = inputFromServlet.readObject();
      if (obj instanceof WorkflowStep) {
        stepInfo = (WorkflowStep) obj;
      } else if (obj instanceof Exception) {
        //otherwise type cast it to Exception and throw that exception.
      throw (Exception) obj;
      }
    }catch(Exception e){
        System.out.println(e);
    }

    if(stepInfo==null){
        jTFSequenceNumber.setText(nextStepSeq);
    } else {
      priorityRuleListValue = stepInfo.getPriorityRuleListValue();
      notificationRuleListValue = stepInfo.getNotificationRuleListValue();
      jTFSequenceNumber.setText(stepInfo.getStepSeq().toString());
        jTFStepName.setText(stepInfo.getStepName());
        //jCBStepType.sett
        jTADescript.setText(stepInfo.getDescription());
        jTFRule.setText(stepInfo.getWorkflowRule());
        if("3".equals(stepInfo.getPriority())){
          jRBHight.setSelected(true);
        } else if("2".equals(stepInfo.getPriority())){
          jRBMiddle.setSelected(true);
        } else if("1".equals(stepInfo.getPriority())){
          jRBLow.setSelected(true);
        }
        if("Y".equals(stepInfo.getAllowStop())){
            jRStopTrue.setSelected(true);
        } else if("N".equals(stepInfo.getAllowStop())){
          jRStopFalse.setSelected(true);
        }
       if("D".equals(stepInfo.getAssignActorType())){
         jCBAssign.setSelected(true);
       }
        if("NA".equals(stepInfo.getOverDueType())){
          jRBDueDate1.setSelected(true);
        } else if("DAYS".equals(stepInfo.getOverDueType())){
          jRBDueDate2.setSelected(true);
          if(stepInfo.getOnNoResponseFor()!=null){
            jTFOnNoResponseFor.setText(stepInfo.getOnNoResponseFor().toString());
          }
        } else if("DATE".equals(stepInfo.getOverDueType())){
          jRBDueDate3.setSelected(true);
          jTFOnNoResponseAfter.setText(stepInfo.getOnNoResponseAfter().toString());
        } else if("ASSIGN".equals(stepInfo.getOverDueType())){
          jRBDueDate4.setSelected(true);
          if("M".equals(stepInfo.getAllowAssignDueDate())){
            jCBallowAssignDueDate.setSelected(true);
          }
        }
        String[] userAry = WindowUtilities.toIDsAry(stepInfo.getUserRecords());
        String[] roleAry = WindowUtilities.toIDsAry(stepInfo.getUserRoles());
        String[] groupAry = WindowUtilities.toIDsAry(stepInfo.getUserGroups());
        String[] actorTypeAry = WindowUtilities.toIDsAry(stepInfo.getActorTypes());
        WindowUtilities.setListItemByIDs(userList,userAry);
        WindowUtilities.setListItemByIDs(roleList,roleAry);
        WindowUtilities.setListItemByIDs(groupList,groupAry);
        WindowUtilities.setListItemByIDs(jListSpecialActor,actorTypeAry);
        //set section value to list
        if (stepInfo.getSectionID()  != null) {
          String sectionID,sectionRID ;
          StringTokenizer sTokenSum = new StringTokenizer(stepInfo.getSectionID(), "|");
          if( sTokenSum.hasMoreElements()){
            sectionID = (String) sTokenSum.nextElement();
            StringTokenizer sToken = new StringTokenizer(sectionID, ",");
            String[] setSectionIDArray = new String[sToken.countTokens()];
            for (int i = 0; sToken.hasMoreElements(); i++) {
              setSectionIDArray[i] = (String) sToken.nextElement();
            }
            WindowUtilities.setListItemByIDs(formSectionEList, setSectionIDArray);
          }
          if( sTokenSum.hasMoreElements()){
            sectionRID = (String)sTokenSum.nextElement() ;
            StringTokenizer sToken = new StringTokenizer(sectionRID, ",");
            String[] setSectionIDArray = new String[sToken.countTokens()];
            for (int i = 0; sToken.hasMoreElements(); i++) {
              setSectionIDArray[i] = (String) sToken.nextElement();
            }
            WindowUtilities.setListItemByIDs(formSectionRList, setSectionIDArray);
          }
        }

        WindowUtilities.setListItemByID(jCBActionAfterDueDate1,stepInfo.getOnNoResponseAction());
        if(!Utility.isEmpty(stepInfo.getOnNoResponseNextStepID())){
          WindowUtilities.setListItemByID(jCBActionAfterDueDate2,stepInfo.getOnNoResponseNextStepID().toString());
        }

        if(!Utility.isEmpty(stepInfo.getFilterBy())){
          WindowUtilities.setListItemByID(jCBFitterBy,stepInfo.getFilterBy().toString());
        }

        if(!Utility.isEmpty(stepInfo.getActionType())){
          WindowUtilities.setListItemByID(jCBStepType,stepInfo.getActionType());
        }

        if ("A".equals(stepInfo.getNotifyOwnerTaskArrivalByMail())){
         jCB1ByMail.setSelected(true);
        }
        if ("B".equals(stepInfo.getNotifyOwnerTaskArrivalBySystem())){
          jCB1BySystem.setSelected(true);
        }
        if ("C".equals(stepInfo.getNotifyAllTaskCompletedByMail())){
          jCB2ByMail.setSelected(true);
        }
        if ("D".equals(stepInfo.getNotifyAllTaskCompletedBySystem())){
          jCB2BySystem.setSelected(true);
        }
        if ("E".equals(stepInfo.getNotifyOwnerTaskOverdueByMail())){
          jCB3ByMail.setSelected(true);
        }
        if ("F".equals(stepInfo.getNotifyOwnerTaskOverdueBySystem())){
          jCB3BySystem.setSelected(true);
        }
        if ("G".equals(stepInfo.getNotifyAllTaskOverdueByMail())){
          jCB4ByMail.setSelected(true);
        }
        if ("H".equals(stepInfo.getNotifyAllTaskOverdueBySystem())){
          jCB4BySystem.setSelected(true);
        }
    }

  }

  /**
   * setWindowInfoToRecord
   *
   */
  public boolean setWindowInfoToRecord(){

    if(jTFSequenceNumber.getText()!= "" && jTFSequenceNumber.getText()!= null){
        //this.workflowStepRecord.setNumOfRoutine(jTFRule.getText());
    }
    if(jTFSequenceNumber.getText()!= "" && jTFSequenceNumber.getText()!= null){
      GPUserObject userObject;
      if(cell.getUserObject() instanceof GPUserObject){
        userObject = (GPUserObject)cell.getUserObject();
      } else {
        userObject =new GPUserObject();
      }

      userObject.setValue(jTFSequenceNumber.getText()+"."+jTFStepName.getText());
      //userObject.putProperty("ID",stepInfo.getID().toString());
      if(jCBStepType.getSelectedIndex()>0){
        userObject.putProperty("STEPTYPE", ((ListObject)jCBStepType.getItemAt(jCBStepType.getSelectedIndex())).getID().toString());
      }
      
      cell.setUserObject(userObject);
    }

    //this.workflowStepRecord.setStepName(jTFStepName.getText());
    //this.workflowStepRecord.setDescription(jTADescript.getText());
    boolean isSuccess = false;
    try{
        httpOperation.reset() ;
        httpOperation.setSubmissionURL(maintWorkflowRecordURL);

        httpOperation.addHtmlFormText(new HtmlFormText("navMode", this.navMode ));

        if(!Utility.isEmpty(stepInfo)){
          httpOperation.addHtmlFormText(new HtmlFormText("opMode", "UPD" ));
          httpOperation.addHtmlFormText(new HtmlFormText("updateCount", stepInfo.getUpdateCount().toString() ));
          httpOperation.addHtmlFormText(new HtmlFormText("ID", stepInfo.getID().toString() ));
          httpOperation.addHtmlFormText(new HtmlFormText("recordStatus", this.recordStatus ));
          httpOperation.addHtmlFormText(new HtmlFormText("creatorID", this.creatorID ));
          httpOperation.addHtmlFormText(new HtmlFormText("createDate", this.createDate ));
          httpOperation.addHtmlFormText(new HtmlFormText("updaterID", this.updaterID ));
          httpOperation.addHtmlFormText(new HtmlFormText("updateDate", this.updateDate ));
          httpOperation.addHtmlFormText(new HtmlFormText("categoryID", stepInfo.getCategroyID() ));

       } else {
         httpOperation.addHtmlFormText(new HtmlFormText("opMode", "INS" ));
       }
        httpOperation.addHtmlFormText(new HtmlFormText("workflowRecordID", workflowRecordID));
        httpOperation.addHtmlFormText(new HtmlFormText("stepName", jTFStepName.getText() ));
        httpOperation.addHtmlFormText(new HtmlFormText("stepSeq", jTFSequenceNumber.getText() ));
        httpOperation.addHtmlFormText(new HtmlFormText("description", jTADescript.getText() ));
        httpOperation.addHtmlFormText(new HtmlFormText("onNoResponseFor", jTFOnNoResponseFor.getText() ));
        httpOperation.addHtmlFormText(new HtmlFormText("onNoResponseAfter", jTFOnNoResponseAfter.getText() ));
        if(jRBHight.isSelected()){
            httpOperation.addHtmlFormText(new HtmlFormText("priority", "3"));
        } else if(jRBMiddle.isSelected()){
            httpOperation.addHtmlFormText(new HtmlFormText("priority", "2"));
        } else if(jRBLow.isSelected()){
          httpOperation.addHtmlFormText(new HtmlFormText("priority", "1"));
        }
        if(jRStopTrue.isSelected()){
            httpOperation.addHtmlFormText(new HtmlFormText("allowStop", "Y"));
        } else if(jRStopFalse.isSelected()){
            httpOperation.addHtmlFormText(new HtmlFormText("allowStop", "N"));
        }
        if(jRBDueDate1.isSelected()){
          httpOperation.addHtmlFormText(new HtmlFormText("overDueType", "NA"));
          jTFOnNoResponseFor.setText("");
          jTFOnNoResponseAfter.setText("");
        } else if(jRBDueDate2.isSelected()){
          httpOperation.addHtmlFormText(new HtmlFormText("overDueType", "DAYS"));
          jTFOnNoResponseAfter.setText("");
        } else if(jRBDueDate3.isSelected()){
        	httpOperation.addHtmlFormText(new HtmlFormText("overDueType", "DATE"));
        	jTFOnNoResponseFor.setText("");
        } else if(jRBDueDate4.isSelected()){
          httpOperation.addHtmlFormText(new HtmlFormText("overDueType", "ASSIGN"));
          jTFOnNoResponseFor.setText("");
          jTFOnNoResponseAfter.setText("");
          if(jCBallowAssignDueDate.isSelected()){
            httpOperation.addHtmlFormText(new HtmlFormText("allowAssignDueDate", "M"));
          } else {
            httpOperation.addHtmlFormText(new HtmlFormText("allowAssignDueDate", "Y"));
          }
        }
        
        /*if(jRBWorkflowSubmitter.isSelected()){
          httpOperation.addHtmlFormText(new HtmlFormText("actorType", "S"));
        }else if(jRBSubmitReportTo.isSelected()){
          httpOperation.addHtmlFormText(new HtmlFormText("actorType", "M"));
        }else if(jRBPreviousTaskOwner.isSelected()){
          httpOperation.addHtmlFormText(new HtmlFormText("actorType", "P"));
        }else if(jRBPreviousTaskOwnerReportTo.isSelected()){
          httpOperation.addHtmlFormText(new HtmlFormText("actorType", "V"));
        }else if(jRBAssignAtRuntime.isSelected()){
          httpOperation.addHtmlFormText(new HtmlFormText("actorType", "D"));
        } else {
          httpOperation.addHtmlFormText(new HtmlFormText("actorType", ""));
        }*/
        if(jCBAssign.isSelected()){
          httpOperation.addHtmlFormText(new HtmlFormText("assignActorType", "D"));
        }
        Object[] selectUser = userList.getSelectedValues();
        for(int i=0;i<selectUser.length;i++){
          httpOperation.addHtmlFormText(new HtmlFormText("userRecords", ((ListObject)selectUser[i]).getID()));
        }
        Object[] selectRole = roleList.getSelectedValues();
        for(int i=0;i<selectRole.length;i++){
          httpOperation.addHtmlFormText(new HtmlFormText("userRoles", ((ListObject)selectRole[i]).getID()));
        }
        Object[] selectGroup = groupList.getSelectedValues();
        for(int i=0;i<selectGroup.length;i++){
          httpOperation.addHtmlFormText(new HtmlFormText("userGroups", ((ListObject)selectGroup[i]).getID()));
        }
        Object[] selectActorType = jListSpecialActor.getSelectedValues();
        for(int i=0;i<selectActorType.length;i++){
          httpOperation.addHtmlFormText(new HtmlFormText("actorTypes", ((ListObject)selectActorType[i]).getID()));
        }

        Object[] selectFormSectionE = formSectionEList.getSelectedValues();
        for(int i=0;i<selectFormSectionE.length;i++){
          httpOperation.addHtmlFormText(new HtmlFormText("sectionID", ((ListObject)selectFormSectionE[i]).getID()));
        }
        Object[] selectFormSectionR = formSectionRList.getSelectedValues();
        for(int i=0;i<selectFormSectionR.length;i++){
          httpOperation.addHtmlFormText(new HtmlFormText("sectionRID", ((ListObject)selectFormSectionR[i]).getID()));
        }

        httpOperation.addHtmlFormText(new HtmlFormText("onNoResponseAction",((ListObject)jCBActionAfterDueDate1.getItemAt(jCBActionAfterDueDate1.getSelectedIndex())).getID().toString()));
        httpOperation.addHtmlFormText(new HtmlFormText("onNoResponseNextStepID",((ListObject)jCBActionAfterDueDate2.getItemAt(jCBActionAfterDueDate2.getSelectedIndex())).getID().toString()));
        httpOperation.addHtmlFormText(new HtmlFormText("filterBy",((ListObject)jCBFitterBy.getItemAt(jCBFitterBy.getSelectedIndex())).getID().toString()));
        String actionType="";
        if(stepInfo!=null){
          actionType = stepInfo.getActionType();
        }       
        if(WorkflowStep.ACTION_TYPE_SUBMIT.equals(actionType)||WorkflowStep.ACTION_TYPE_END.equals(actionType)){
          httpOperation.addHtmlFormText(new HtmlFormText("actionType",actionType));
        } else {
          httpOperation.addHtmlFormText(new HtmlFormText("actionType",((ListObject)jCBStepType.getItemAt(jCBStepType.getSelectedIndex())).getID().toString()));
        }
        if(jCB1ByMail.isSelected()){
          httpOperation.addHtmlFormText(new HtmlFormText("notifyOwnerTaskArrivalByMail", "A"));
        }
        if(jCB1BySystem.isSelected()){
          httpOperation.addHtmlFormText(new HtmlFormText("notifyOwnerTaskArrivalBySystem", "B"));
        }
        if(jCB2ByMail.isSelected()){
          httpOperation.addHtmlFormText(new HtmlFormText("notifyAllTaskCompletedByMail", "C"));
        }
        if(jCB2BySystem.isSelected()){
          httpOperation.addHtmlFormText(new HtmlFormText("notifyAllTaskCompletedBySystem", "D"));
        }
        if(jCB3ByMail.isSelected()){
          httpOperation.addHtmlFormText(new HtmlFormText("notifyOwnerTaskOverdueByMail", "E"));
        }
        if(jCB3BySystem.isSelected()){
          httpOperation.addHtmlFormText(new HtmlFormText("notifyOwnerTaskOverdueBySystem", "F"));
        }
        if(jCB1ByMail.isSelected()){
          httpOperation.addHtmlFormText(new HtmlFormText("notifyAllTaskOverdueByMail", "G"));
        }
        if(jCB4BySystem.isSelected()){
          httpOperation.addHtmlFormText(new HtmlFormText("notifyAllTaskOverdueBySystem", "H"));
        }


        //httpOperation.addHtmlFormText(new HtmlFormText("filterBy", ""));
        httpOperation.addHtmlFormText(new HtmlFormText("workflowRule", jTFRule.getText()));
        if(!Utility.isEmpty(priorityRuleListValue)){
          httpOperation.addHtmlFormText(new HtmlFormText("priorityRuleListValue", priorityRuleListValue));
        }
        
        if(!Utility.isEmpty(notificationRuleListValue)){
          httpOperation.addHtmlFormText(new HtmlFormText("notificationRuleListValue", notificationRuleListValue));
        }
        


        //Object[] selectObject = jList.getSelectedValues();
        //for(int i=0;i<selectObject.length;i++){
            //httpOperation.addHtmlFormText(new HtmlFormText("categoryObjectID", ((ListObject)selectObject[i]).getID().toString()));
        //}

        String returnValue = httpOperation.transmit().toString();
        returnValue = returnValue.replaceAll("\n","");

        Editor editor = this.getEditor();
        editor.outputMessage(returnValue, false);
        isSuccess = true;
    }catch(Exception e){
      e.printStackTrace();
        isSuccess = false;
    }
    return isSuccess;
  }


  public void setWorkflowStepRecord(WorkflowStepRecord workflowStepRecord){
    this.workflowStepRecord = workflowStepRecord ;
  }

  protected boolean checkValue(){
    if("".equals(jTFSequenceNumber.getText())){
      String message = WindowUtilities.getResouceByCode(httpOperation, hostURL, new int[]{0,82});
      editor.outputMessage(message, false);
      return false;
    }
    if("".equals(jTFStepName.getText())){
      String message = WindowUtilities.getResouceByCode(httpOperation, hostURL, new int[]{0,81});
      editor.outputMessage(message, false);
      return false;
    }
    int selectUser = userList.getSelectedIndex();
    int selectRole = roleList.getSelectedIndex();
    int selectGroup = groupList.getSelectedIndex();
    String stepType = ((ListObject)jCBStepType.getItemAt(jCBStepType.getSelectedIndex())).getID();
    if(!stepType.substring(0, 1).equals("C")){
      //if(jRNoneOfAbove.isSelected()){
        if(selectUser==-1&&selectRole==-1&&selectGroup==-1){
          //editor.outputMessage(AppletResource.lableArr[200], false);
          //return false;
        }
      //}
    }

    return true;

  }

  void jBPriority_actionPerformed(ActionEvent e) {
    PirorityRule pirorityRule = new PirorityRule(httpOperation, priorityRuleListValue,this, "Pirority Rule", true);
    pirorityRule.setBounds(editor.getX(),editor.getY(),630,320);
    pirorityRule.setLocationRelativeTo(editor);
    
    //pirorityRule.initData(workflowRecordID.toString(),httpOperation,hostURL,Editor.this);
    pirorityRule.show();
    
    //connectType =(GPUserObject)edge.getUserObject();
  }

  void jBNotification_actionPerformed(ActionEvent e) {
    NotificationRule notificationRule = new NotificationRule(httpOperation, notificationRuleListValue,this, "Notification Rule", true);
    notificationRule.setBounds(editor.getX(),editor.getY(),630,320);
    notificationRule.setLocationRelativeTo(editor);
    
    //pirorityRule.initData(workflowRecordID.toString(),httpOperation,hostURL,Editor.this);
    notificationRule.show();
  }

}

class StepInformationWindow_jButton4_actionAdapter implements java.awt.event.ActionListener {
  StepInformationWindow adaptee;

  StepInformationWindow_jButton4_actionAdapter(StepInformationWindow adaptee) {
    this.adaptee = adaptee;
  }
  public void actionPerformed(ActionEvent e) {
    adaptee.jButton4_actionPerformed(e);
  }
}

class StepInformationWindow_jButton5_actionAdapter implements java.awt.event.ActionListener {
  StepInformationWindow adaptee;

  StepInformationWindow_jButton5_actionAdapter(StepInformationWindow adaptee) {
    this.adaptee = adaptee;
  }
  public void actionPerformed(ActionEvent e) {
    adaptee.jButton5_actionPerformed(e);
  }
}

class WorkflowUserInfo {
  private Integer ID;
  private String  name ;
  public Integer getID(){
      return this.ID;
  }

  public String getName(){
      return this.name ;
  }

  public void setID(Integer ID){
      this.ID = ID;
  }

  public void setName(String name){
      this.name = name;
  }

  public String toString(){
      return this.name ;
  }


}

class StepInformationWindow_jBPriority_actionAdapter implements java.awt.event.ActionListener {
  StepInformationWindow adaptee;

  StepInformationWindow_jBPriority_actionAdapter(StepInformationWindow adaptee) {
    this.adaptee = adaptee;
  }
  public void actionPerformed(ActionEvent e) {
    adaptee.jBPriority_actionPerformed(e);
  }
}

class StepInformationWindow_jBNotification_actionAdapter implements java.awt.event.ActionListener {
  StepInformationWindow adaptee;

  StepInformationWindow_jBNotification_actionAdapter(StepInformationWindow adaptee) {
    this.adaptee = adaptee;
  }
  public void actionPerformed(ActionEvent e) {
    adaptee.jBNotification_actionPerformed(e);
  }
}
